package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.TbChatPage;
import com.ruoyi.system.service.ITbChatPageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 聊天界面Controller
 * 
 * @author ruoyi
 * @date 2024-09-14
 */
@RestController
@RequestMapping("/chatpage")
public class TbChatPageController extends BaseController
{
    @Autowired
    private ITbChatPageService tbChatPageService;

    /**
     * 查询聊天界面列表
     */
//    @RequiresPermissions("system:chatpage:list")
    @GetMapping("/list")
    public TableDataInfo list(TbChatPage tbChatPage)
    {
        startPage();
        List<TbChatPage> list = tbChatPageService.selectTbChatPageList(tbChatPage);
        return getDataTable(list);
    }

    /**
     * 导出聊天界面列表
     */
    @RequiresPermissions("system:chatpage:export")
    @Log(title = "聊天界面", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbChatPage tbChatPage)
    {
        List<TbChatPage> list = tbChatPageService.selectTbChatPageList(tbChatPage);
        ExcelUtil<TbChatPage> util = new ExcelUtil<TbChatPage>(TbChatPage.class);
        util.exportExcel(response, list, "聊天界面数据");
    }

    /**
     * 获取聊天界面详细信息
     */
    @RequiresPermissions("system:chatpage:query")
    @GetMapping(value = "/{chatId}")
    public AjaxResult getInfo(@PathVariable("chatId") Long chatId)
    {
        return success(tbChatPageService.selectTbChatPageByChatId(chatId));
    }

    /**
     * 新增聊天界面
     */
    @RequiresPermissions("system:chatpage:add")
    @Log(title = "聊天界面", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbChatPage tbChatPage)
    {
        return toAjax(tbChatPageService.insertTbChatPage(tbChatPage));
    }

    /**
     * 修改聊天界面
     */
    @RequiresPermissions("system:chatpage:edit")
    @Log(title = "聊天界面", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbChatPage tbChatPage)
    {
        return toAjax(tbChatPageService.updateTbChatPage(tbChatPage));
    }

    /**
     * 删除聊天界面
     */
    @RequiresPermissions("system:chatpage:remove")
    @Log(title = "聊天界面", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chatIds}")
    public AjaxResult remove(@PathVariable Long[] chatIds)
    {
        return toAjax(tbChatPageService.deleteTbChatPageByChatIds(chatIds));
    }
}
